home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / terminal / sysline-.1 / sysline- / sysline-1.1 / cs < prev    next >
Encoding:
Text File  |  1996-03-13  |  981 b   |  38 lines

  1. #!/bin/sh
  2.  
  3. # cs top bottom
  4. # set scroll-region to lines $1 - $2 (1-based)
  5. # the resulting free area can be used for a status-line -- bjd
  6.  
  7. # comment out or change WHICH_TPUT to whatever is appropriate
  8.  
  9. # -- GNU termcap-based tput (which I call tcput):
  10. #WHICH_TPUT=tcput
  11. # -- Ncurses terminfo-based tput:
  12. WHICH_TPUT=tput
  13.  
  14.  
  15. if [ ! $# -eq 2 ]
  16. then
  17.     echo "usage: $0 top bottom (1-based)"
  18.     echo "e.g. cs 2 28 for a scroll-region of lines 2-28 inclusive"
  19.     exit
  20. fi
  21.  
  22. stty rows $((${2}-${1}+1))        # let kernel know about it
  23.  
  24. if TPUT=`type -path $WHICH_TPUT`
  25. then
  26.     # we have a tput...
  27.     $TPUT clear            # clear screen
  28.     # csr expects 0-based parameters, so decrement ours
  29.     $TPUT csr $(($1-1)) $(($2-1))    # set scroll-region to line $1 -- $2
  30.     $TPUT home
  31. else
  32.     # try this then...
  33.     #echo -en "\033c"        # overkill, is a reset
  34.     echo -en "\033[H\033[J"        # clear screen
  35.     echo -en "\033[${1};${2}r"    # set scroll-region to line $1 -- $2
  36.     echo -en "\033[${1};1H"        # position cursor at top of scroll-region
  37. fi
  38.